#include "processBar.h"
#include <unistd.h>

typedef void (*callback_t)(int);
void downLoad(callback_t pf)
{

    int total = 1000;
    int curr = 0;
    while(curr <= total)
    {
        int rate = curr * 100/ total;
        pf(rate);
        //进行着某种下载任务
        curr += 10;
        usleep(50000);
    }
    printf("\n");
    initbar();
}
int main()
{
    printf("downLoad1:\n");
    downLoad(processbar);
    printf("downLoad2:\n");
    downLoad(processbar);
    printf("downLoad3:\n");
    downLoad(processbar);
    printf("downLoad4:\n");
    downLoad(processbar);
    return 0;

/*    int cnt = 10;
    while(cnt)
    {
        printf("%-2d\r",cnt);
        fflush(stdout);
        cnt--;
        sleep(1);
    }
    
    printf("\n");

    //printf("hello world");  // 1
    //fflush(stdout);
    //sleep(2);               // 2
*/
    
}
